package com.xiangxiao.rpan.storage.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xiangxiao.rpan.storage.enums.FileTypeEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.StringJoiner;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/10/19 15:59
 */
@Data
public class FileItemResult implements Serializable {
  private String name;

  @JSONField(format = "yyyy-MM-dd HH:mm:ss")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private String time;

  private Long size;

  private FileTypeEnum type;

  private String path;

  private String url;

  /**
   * 获取路径和名称的组合, 并移除重复的路径分隔符 /.
   *
   * @return  路径和名称的组合
   */
  public String getFullPath() {
    StringJoiner sj = new StringJoiner("");
    sj.add(path);
    sj.add("/");
    sj.add(name);
    return sj.toString();
  }
}
